c++ 基础数据类型 与 uint8 您所在的位置:网站首页 printf uint16 c++ 基础数据类型 与 uint8

c++ 基础数据类型 与 uint8

2024-07-16 22:33| 来源: 网络整理| 查看: 265

C++的基础数据类型:

C++的主要数据类型,主要分为三类:布尔型,整型(char型从本质上说,也是种整型类型,它是长度为1的整数,通常用来存放字符的ASCII码),浮点型。

而 *_t是typedef定义的表示标志,是结构的一种标注。即我们所看到的 uint8_t、uint16_t、uint32_t都不是新的数据类型,而是通过typedef给类型起得别名。

uint8_t / uint16_t / uint32_t /uint64_t 是什么数据类型

这些数据类型是 C99 中定义的,具体定义在:/usr/include/stdint.h    ISO C99: 7.18 Integer types

/* There is some amount of overlap with as known by inet code */ #ifndef __int8_t_defined # define __int8_t_defined typedef signed char int8_t; typedef short int int16_t; typedef int int32_t; # if __WORDSIZE == 64 typedef long int int64_t; # else __extension__ typedef long long int int64_t; # endif #endif /* Unsigned. */ typedef unsigned char uint8_t; typedef unsigned short int uint16_t; #ifndef __uint32_t_defined typedef unsigned int uint32_t; # define __uint32_t_defined #endif #if __WORDSIZE == 64 typedef unsigned long int uint64_t; #else __extension__ typedef unsigned long long int uint64_t; #endif

注意,uint8_t实际上就是一个char,所以输出 uint8_t类型的变量实际上输出对应的字符,而不是数值,比如:

uint8_t  num=67; cout



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有